package server.model.players;
import server.util.Misc;

public class DialogueHandler {

	private Client c;
	
	public DialogueHandler(Client client) {
		this.c = client;
	}
	
	/**
	 * Handles all talking
	 * @param dialogue The dialogue you want to use
	 * @param npcId The npc id that the chat will focus on during the chat
	 */
	public void sendDialogues(int dialogue, int npcId) {
		c.talkingNpc = npcId;
		switch(dialogue) {
		case 0:
			c.talkingNpc = -1;
			c.getPA().removeAllWindows();
			c.nextChat = 0;
			break;
		/*case 1:
			sendStatement("You found a hidden tunnel! Do you want to enter it?");
			c.dialogueAction = 1;
			c.nextChat = 2;
			break;
		case 2:
			sendOption2("Yea! I'm fearless!",  "No way! That looks scary!");
			c.dialogueAction = 1;
			c.nextChat = 0;
			break;*/
		case 3:
			sendNpcChat4("Hello!", "My name is Duradel and I am a master of the slayer skill.", "I can assign you a slayer task suitable to your combat level.", 
			"Would you like a slayer task?", c.talkingNpc, "Duradel");
			c.nextChat = 4;
		break;
		case 5:
			sendNpcChat4("Hello adventurer...", "My name is Kolodion, the master of this mage bank.", "Would you like to play a minigame in order ", 
						"to earn points towards recieving magic related prizes?", c.talkingNpc, "Kolodion");
			c.nextChat = 6;
		break;
		case 6:
			sendNpcChat4("The way the game works is as follows...", "You will be teleported to the wilderness,", 
			"You must kill mages to recieve points,","redeem points with the chamber guardian.", c.talkingNpc, "Kolodion");
			c.nextChat = 15;
		break;
		case 11:
			sendNpcChat4("Hello!", "My name is Duradel and I am a master of the slayer skill.", "I can assign you a slayer task suitable to your combat level.", 
			"Would you like a slayer task?", c.talkingNpc, "Duradel");
			c.nextChat = 12;
		break;
		case 12:
			sendOption2("Yes I would like a slayer task.", "No I would not like a slayer task.");
			c.dialogueAction = 5;
		break;
		case 13:
			sendNpcChat4("Hello!", "My name is Duradel and I am a master of the slayer skill.", "I see I have already assigned you a task to complete.", 
			"Would you like me to give you an easier task?", c.talkingNpc, "Duradel");
			c.nextChat = 14;
		break;
		case 14:
			sendOption2("Yes I would like an easier task.", "No I would like to keep my task.");
			c.dialogueAction = 6;
		break;
		case 15:
			sendOption2("Yes I would like to play", "No, sounds too dangerous for me.");
			c.dialogueAction = 7;
		break;
		case 16:
			sendOption2("I would like to fix all my barrows.", "Cancel");
			c.dialogueAction = 8;
		break;
		case 17:
			sendOption5("Air", "Mind", "Water", "Earth", "More");
			c.dialogueAction = 10;
			c.dialogueId = 17;
			c.teleAction = -1;
		break;
		case 18:
			sendOption5("Fire", "Body", "Cosmic", "Astral", "More");
			c.dialogueAction = 11;
			c.dialogueId = 18;
			c.teleAction = -1;
		break;
		case 19:
			sendOption5("Nature", "Law", "Death", "Blood", "More");
			c.dialogueAction = 12;
			c.dialogueId = 19;
			c.teleAction = -1;
		break;
		case 20:
			sendNpcChat1("Would you like to ride the flying carpet for 200 gold?", c.talkingNpc, "Rug Merchant");
			c.nextChat = 21;
		break;
		case 21:
			sendOption2("Yes",  "No");
			c.dialogueAction = 13;
		break;
		case 22:
			sendNpcChat1("You currently have "+c.pkPoints+" PK points.", c.talkingNpc, "Mazchna");
		break;
		case 23:
			sendOption3("KBD [NOT SAFE]", "War Pk", "Falador Pk");
			c.dialogueAction = 14;
		break;
		case 24:
				if(c.pureAmount == 0 && c.mainAmount == 0 && c.zerkAmount == 0){
c.haveTask = 0;
}
		if(c.haveTask == 0) {
			sendNpcChat1("Hello! Would you like to start a Pking task?", c.talkingNpc, "Vannaka");
			} else {
			sendNpcChat1("I see you would like to manage your task.", c.talkingNpc, "Vannaka");
			}
			c.nextChat = 25;
		break;
		case 25:
		sendPlayerChat1("I sure would!");
			c.nextChat = 26;
			break;
		case 26:
				if(c.pureAmount == 0 && c.mainAmount == 0 && c.zerkAmount == 0){
c.haveTask = 0;
}
		if(c.haveTask == 0) {
		sendOption2("Start New Task!",  "Don't Worry..");
		} else {
		sendOption2("View Task!",  "Reset Task!");
		}
			c.dialogueAction = 15;
		break;
		case 27:
		if(c.pureAmount == 0 && c.mainAmount == 0 && c.zerkAmount == 0){
c.haveTask = 0;
}
		if(c.haveTask == 0) {
		c.taskSelect = Misc.random(2);
		c.taskRandom = Misc.random(30);
		c.haveTask = 1;
		if(c.taskSelect == 0) {
		c.pureTask = 1;
		c.pureAmount = c.taskRandom;
		sendNpcChat1("Your task is to kill "+c.pureAmount+" pures!", c.talkingNpc, "Vannaka");
		} else if (c.taskSelect == 1) {
		c.zerkTask = 1;
		c.zerkAmount = c.taskRandom;
		sendNpcChat1("Your task is to kill "+c.zerkAmount+" zerkers!", c.talkingNpc, "Vannaka");
		} else if (c.taskSelect == 2) {
		c.mainTask = 1;
		c.mainAmount = c.taskRandom;
		sendNpcChat1("Your task is to kill "+c.mainAmount+" main accounts!", c.talkingNpc, "Vannaka");
		}
		} else if (c.haveTask >= 1) {
		if(c.taskSelect == 0) {
		sendNpcChat1("You currently have "+c.pureAmount+" pures left to kill!", c.talkingNpc, "Vannaka");
		} else if (c.taskSelect == 1) {
		sendNpcChat1("You currently have "+c.zerkAmount+" zerkers left to kill!", c.talkingNpc, "Vannaka");
		} else if (c.taskSelect == 2) {
		sendNpcChat1("You currently have "+c.mainAmount+" main accounts left to kill!", c.talkingNpc, "Vannaka");
		}
		}
		c.nextChat = 0;
		break;
		case 28:
		sendNpcChat1("Yo, wait up a minute "+c.playerName+"!", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 29;
		break;
		case 29:
		sendNpcChat1("Let me just tell you how the server works first.", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 30;
		break;
		case 30:
		sendNpcChat1("The NPC's to the right are shops", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 31;
		break;
		case 31:
		sendNpcChat1("These sell you gear for PK'ing and levelling!", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 32;
		break;
		case 32:
		sendNpcChat1("The altars in the room to the left are magic switchers!", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 33;
		break;
		case 33:
		sendNpcChat1("That means when you left click them, you get lunar/ancients!", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 34;
		break;
		case 34:
		sendNpcChat1("Also, you can talk to menzcha for the PvP store", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 35;
		break;
		case 35:
		sendNpcChat1("Or you can talk to vannaka for a PvP task!", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 36;
		break;
		case 36:
		sendPlayerChat1("Thanks random mystery guide!");
		c.nextChat = 0;

		c.firstEnter = 1;
		c.sendMessage("Congratulations, you have learned something new about the server!");
		c.sendMessage("The ExtinctionPK guide slips 5m into your pack as thanks!");
		c.getItems().addItem(995,5000000);
		break;
		case 37:
		sendNpcChat1("Hey man just thought id tell you about the wild!", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 38;
		break;
		case 38:
		sendPlayerChat1("If you give me 5m...?");
		c.nextChat = 39;
		break;
		case 39:
		sendNpcChat1("Kk get a space free in your pack.", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 40;
		break;
		case 40:
		sendPlayerChat1("Go for it ;D.");
		c.nextChat = 41;
		break;
		case 41:
		sendNpcChat1("Outside of here is what we call a PvP zone.", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 42;
		break;
		case 42:
		sendNpcChat1("That means other players can attack you!", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 43;
		break;
		case 43:
		sendNpcChat1("But that isn't the best part >:D", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 44;
		break;
		case 44:
		sendNpcChat1("By talking to vannaka you can get PvP tasks!", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 45;
		break;
		case 45:
		sendNpcChat1("These give you almost triple PvP points!!", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 46;
		break;
		case 46:
		sendPlayerChat1("PvP Points?");
		c.nextChat = 47;
		break;
		case 47:
		sendNpcChat1("Yeah, talk to menzcha at home to spend them.", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 48;
		break;
		case 48:
		sendPlayerChat1("Cya bro");
		c.nextChat = 0;
						c.firstWild = 1;
		c.sendMessage("Congratulations, you have learned something new about the server!");
		c.sendMessage("The ExtinctionPK guide slips 5m into your pack as a thanks!");
		c.getItems().addItem(995,5000000);
		break;
		case 49:
		sendNpcChat1("Get pk points by defeating players in the pvp zone!.", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 0;
		break;
		case 50:
		sendNpcChat1("That costs 10 PkP, are you sure you want to do that?", c.talkingNpc, "ExtinctionPK Guide");
		c.nextChat = 51;
		break;
		case 51:
		sendOption2("Yes!",  "No Thanks");
		c.dialogueAction = 90;
		c.nextChat = 0;
		break;
		case 52:
		sendNpcChat4("Congratulations!","You have killed 20 monkeys hope you learned something..", "would you like to escape?","Do not break anymore rules!", c.talkingNpc, "Mosol Rei");
		c.dialogueAction = 26;
		c.nextChat = 53;
		break;
		case 53:
		sendOption2("Yes get me out of this fucking hell hole!",  "Hell no! I love it here, I'm nuts for these monkeys!");
		c.dialogueAction = 27;
		c.nextChat = 0;	
		break;
		case 54:
		sendNpcChat4("You cannot Escape yet!","You've killed "+c.monkeyk0ed+" out of 20 monkeys!","Come back when you have killed 20","Kthxbai", c.talkingNpc, "Mosol Rei");
		c.dialogueAction = 30;
		c.nextChat = 0;
		break;
		case 950:
		sendNpcChat1("Looking try some gambling?",c.talkingNpc, "Gambler");
			c.nextChat = 951;
		break;
		case 951:
		sendOption2("Yes", "No");
			c.dialogueAction = 950;
		break;
		case 952:
		sendPlayerChat1("No thanks.");
			c.nextChat = 955;
		break;
		case 953:
		sendPlayerChat1("Sure, I'm up for taking a risk.");
			c.nextChat = 954;
		break;
		case 954:
		sendNpcChat4("It's a 50/50 chance to win.","Winning doubles your money.","Losing will lose all your money.","Click the chest next to me to get started.",c.talkingNpc, "Gambler");
			c.nextChat = 0;
		break;
		case 955:
		sendNpcChat1("Hmph. Alright then.",c.talkingNpc, "Gambler");
			c.nextChat = 0;
		break;
		case 956:
		sendOption5("Bet 100,000GP", "Bet 250,000gp","Bet 500,000gp","Bet 1,000,000gp","Bet 2,000,000gp");
			c.dialogueAction = 956;
		break;
		case 957:
		c.getPA().sendFrame126("Gamble "+c.betAmount+"?", 2460);
		sendOption2("Gamble "+c.betAmount+"gp", "Chicken Out!");
			c.dialogueAction = 957;
		break;
		case 958:
		sendNpcChat1("You need more coins to bet "+c.betAmount+"gp!",c.talkingNpc, "Gambler");
			c.nextChat = 0;
		break;
		case 959:
		sendNpcChat2("Congratulations..","You win your "+c.betAmount+"gp bet!",c.talkingNpc, "Gambler");
			c.nextChat = 0;
		break;
		case 960:
		sendNpcChat2("Unlucky..","You lose your "+c.betAmount+"gp bet.",c.talkingNpc, "Gambler");
			c.nextChat = 0;
		break;
		case 970:
			sendNpcChat1("Would you like to go to the gnome agility course?", c.talkingNpc, "Gnome Trainer");
			c.nextChat = 971;
		break;
		case 971:
			sendOption2("Yes",  "No");
			c.dialogueAction = 420;
		break;
		}
		}

	public void sendStartInfo(String text, String text1, String text2, String text3, String title) {
		c.getPA().sendFrame126(title, 6180);
		c.getPA().sendFrame126(text, 6181);
		c.getPA().sendFrame126(text1, 6182);
		c.getPA().sendFrame126(text2, 6183);
		c.getPA().sendFrame126(text3, 6184);
		c.getPA().sendFrame164(6179);
	}
	
	/*
	 * Options
	 */
	
	private void sendOption(String s, String s1) {
		c.getPA().sendFrame126("Select an Option", 2470);
	 	c.getPA().sendFrame126(s, 2471);
		c.getPA().sendFrame126(s1, 2472);
		c.getPA().sendFrame126("Click here to continue", 2473);
		c.getPA().sendFrame164(13758);
	}	
	
	public void sendOption2(String s, String s1) {
		c.getPA().sendFrame126("Select an Option", 2460);
		c.getPA().sendFrame126(s, 2461);
		c.getPA().sendFrame126(s1, 2462);
		c.getPA().sendFrame164(2459);
	}
	
	private void sendOption3(String s, String s1, String s2) {
		c.getPA().sendFrame126("Select an Option", 2470);
		c.getPA().sendFrame126(s, 2471);
		c.getPA().sendFrame126(s1, 2472);
		c.getPA().sendFrame126(s2, 2473);
		c.getPA().sendFrame164(2469);
	}
	
	public void sendOption4(String s, String s1, String s2, String s3) {
		c.getPA().sendFrame126("Select an Option", 2481);
		c.getPA().sendFrame126(s, 2482);
		c.getPA().sendFrame126(s1, 2483);
		c.getPA().sendFrame126(s2, 2484);
		c.getPA().sendFrame126(s3, 2485);
		c.getPA().sendFrame164(2480);
	}
	
	public void sendOption5(String s, String s1, String s2, String s3, String s4) {
		c.getPA().sendFrame126("Select an Option", 2493);
		c.getPA().sendFrame126(s, 2494);
		c.getPA().sendFrame126(s1, 2495);
		c.getPA().sendFrame126(s2, 2496);
		c.getPA().sendFrame126(s3, 2497);
		c.getPA().sendFrame126(s4, 2498);
		c.getPA().sendFrame164(2492);
	}

	/*
	 * Statements
	 */
	
	private void sendStatement(String s) { // 1 line click here to continue chat box interface
		c.getPA().sendFrame126(s, 357);
		c.getPA().sendFrame126("Click here to continue", 358);
		c.getPA().sendFrame164(356);
	}
	
	/*
	 * Npc Chatting
	 */
	
	private void sendNpcChat1(String s, int ChatNpc, String name) {
		c.getPA().sendFrame200(4883, 591);
		c.getPA().sendFrame126(name, 4884);
		c.getPA().sendFrame126(s, 4885);
		c.getPA().sendFrame75(ChatNpc, 4883);
		c.getPA().sendFrame164(4882);
	}
	
	private void sendNpcChat2(String s, String s1, int ChatNpc, String name) {
		c.getPA().sendFrame200(4888, 591);
		c.getPA().sendFrame126(name, 4889);
		c.getPA().sendFrame126(s, 4890);
		c.getPA().sendFrame126(s1, 4891);
		c.getPA().sendFrame75(ChatNpc, 4888);
		c.getPA().sendFrame164(4887);
	}
	
	private void sendNpcChat3(String s, String s1, String s2, int ChatNpc, String name) {
		c.getPA().sendFrame200(4894, 591);
		c.getPA().sendFrame126(name, 4895);
		c.getPA().sendFrame126(s, 4896);
		c.getPA().sendFrame126(s1, 4897);
		c.getPA().sendFrame126(s2, 4898);
		c.getPA().sendFrame75(ChatNpc, 4894);
		c.getPA().sendFrame164(4893);
	}
	
	private void sendNpcChat4(String s, String s1, String s2, String s3, int ChatNpc, String name) {
		c.getPA().sendFrame200(4901, 591);
		c.getPA().sendFrame126(name, 4902);
		c.getPA().sendFrame126(s, 4903);
		c.getPA().sendFrame126(s1, 4904);
		c.getPA().sendFrame126(s2, 4905);
		c.getPA().sendFrame126(s3, 4906);
		c.getPA().sendFrame75(ChatNpc, 4901);
		c.getPA().sendFrame164(4900);
	}
	
	/*
	 * Player Chating Back
	 */
	
	private void sendPlayerChat1(String s) {
		c.getPA().sendFrame200(969, 591);
		c.getPA().sendFrame126(c.playerName, 970);
		c.getPA().sendFrame126(s, 971);
		c.getPA().sendFrame185(969);
		c.getPA().sendFrame164(968);
	}
	
	private void sendPlayerChat2(String s, String s1) {
		c.getPA().sendFrame200(974, 591);
		c.getPA().sendFrame126(c.playerName, 975);
		c.getPA().sendFrame126(s, 976);
		c.getPA().sendFrame126(s1, 977);
		c.getPA().sendFrame185(974);
		c.getPA().sendFrame164(973);
	}
	
	private void sendPlayerChat3(String s, String s1, String s2) {
		c.getPA().sendFrame200(980, 591);
		c.getPA().sendFrame126(c.playerName, 981);
		c.getPA().sendFrame126(s, 982);
		c.getPA().sendFrame126(s1, 983);
		c.getPA().sendFrame126(s2, 984);
		c.getPA().sendFrame185(980);
		c.getPA().sendFrame164(979);
	}
	
	private void sendPlayerChat4(String s, String s1, String s2, String s3) {
		c.getPA().sendFrame200(987, 591);
		c.getPA().sendFrame126(c.playerName, 988);
		c.getPA().sendFrame126(s, 989);
		c.getPA().sendFrame126(s1, 990);
		c.getPA().sendFrame126(s2, 991);
		c.getPA().sendFrame126(s3, 992);
		c.getPA().sendFrame185(987);
		c.getPA().sendFrame164(986);
	}
}
